<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>再延时再请求</title>
</head>
<body>
    <script type="text/javascript">
        // 这种情况就造成了回调地狱，因此出现了promise
        setTimeout(() => {
            request.onreadystatechange = () => {
                if (request.readyState == 4) {
                    const status = reques.status
                    if (status === 200) {
                        const res = request.responseText
                        setTimeout(() => {
                            request.onreadystatechange = () => {
                                if (request.readyState == 4) {
                                    const status = reques.status
                                    if (status === 200) {
                                        const res = request.responseText
                                        
                                        return success(request.responseText)
                                    } else {
                                        return fail(err)
                                    }
                                }
                            }
                        }, 1000);
                        return success(request.responseText)
                    } else {
                        return fail(err)
                    }
                }
            }
        }, 1000);
    </script>
</body>
</html>